//引入express模块
const express = require('express')
//引入连接池模块
const pool = require('../pool.js')
//创建路由器对象
const r = express.Router();
//http://127.0.0.1:8080/delete/:uid
//添加路由器删除用户()
r.delete('/delete/:lid',(req,res,next)=>{
    //获取要删除的值
    let obj = req.params;
    console.log(obj);
    //执行sql命令
    pool.query('delete from scp_clothes where  lid=?',[obj.lid],(err,result)=>{
        if(err){
            next(err);
            return;
        }
        console.log(result);
        if(result.affectedRows===0){
            res.send({code:404,msg:'删除失败'});
            return;
        }else{
            res.send({code:200,msg:'删除成功'});
        }
    });
});




//导出路由器对象让app.js获取
module.exports = r;